home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 031a / wedl120.zip / WEDL.H < prev   
Text File  |  1991-12-09  |  15KB  |  288 lines

  1.  
  2. /*---------------------------------------------------------------------------*/
  3. /*                                                                           */
  4. /*          WEDL - Windows Enhanced Dialog Library                           */
  5. /*          Copyright (c) 1991, Mike Smedley                                 */
  6. /*          All Rights Reserved                                              */
  7. /*          Module:  WEDL.H                                                  */
  8. /*                                                                           */
  9. /*---------------------------------------------------------------------------*/
  10.  
  11. /* field feature definitions */
  12.  
  13. #define FDF_NONE        0L      /* no features specified                  */
  14. #define FDF_COMPLETE    1L      /* field must be complete                 */
  15. #define FDF_NOTBLANK    2L      /* field cannot be blank                  */
  16. #define FDF_NOTZERO     4L      /* field cannot be zero                   */
  17. #define FDF_NOTEDIT     8L      /* field cannot be edited                 */
  18. #define FDF_MUSTEDIT    16L     /* field must be edited                   */
  19. #define FDF_UPDATE      32L     /* update existing data                   */
  20. #define FDF_CONDUPD     64L     /* conditionally update existing data     */
  21. #define FDF_SPCFILL     128L    /* space-fill field from right            */
  22. #define FDF_ZEROFILL    256L    /* zero-fill numeric field from left      */
  23. #define FDF_BLNKZERO    512L    /* blank numeric field if equal to zero   */
  24. #define FDF_RDPHYS      1024L   /* read 'pdata' in physical field format  */
  25. #define FDF_WRPHYS      2048L   /* write 'pdata' in physical field format */
  26. #define FDF_UPPER       4096L   /* convert characters to UPPERCASE        */
  27. #define FDF_LOWER       8192L   /* convert characters to lowercase        */
  28. #define FDF_MIXED       16384L  /* convert characters to Mixed Case       */
  29. #define FDF_NUMERIC     32768L  /* standard numeric field                 */
  30. #define FDF_CALCNUM     65536L  /* calculator-style numeric field         */
  31. #define FDF_VAFFLD      131072L /* don't validate until user leaves field */
  32. #define FDF_VAFFRM      262144L /* don't validate until user selects "OK" */
  33. #define FDF_COMBO       524288L /* field belongs to a combo box           */
  34.  
  35. /*---------------------------------------------------------------------------*/
  36.  
  37. /* data type definitions */
  38.  
  39. #define DT_NULL         0       /* 'pdata' pointer == NULL      */
  40. #define DT_STRING       1       /* character string             */
  41. #define DT_INTEGER      2       /* signed integer               */
  42. #define DT_UNSIGNED     3       /* unsigned integer             */
  43. #define DT_LONG         4       /* signed long integer          */
  44. #define DT_ULONG        5       /* unsigned long integer        */
  45. #define DT_DOUBLE       6       /* double precision real number */
  46.  
  47. /*---------------------------------------------------------------------------*/
  48.  
  49. /* button state definitions */
  50.  
  51. #define BS_OFF          0       /* button is off (not checked)             */
  52. #define BS_ON           1       /* button is on (checked)                  */
  53. #define BS_GRAYED       2       /* a 3-state button is grayed (disabled)   */
  54. #define BS_USEDATA      3       /* use value of data pointed to by 'pdata' */
  55. #define BS_NOTSET       4       /* do not set state of button              */
  56.  
  57. /*---------------------------------------------------------------------------*/
  58.  
  59. /* status message definitions */
  60.  
  61. #define SM_INSERT       0       /* Insert key status message    */
  62. #define SM_CAPSLOCK     1       /* CapsLock key status message  */
  63. #define SM_NUMLOCK      2       /* NumLock key status message   */
  64.  
  65. /*---------------------------------------------------------------------------*/
  66.  
  67. typedef HANDLE  HFORM;          /* handle of a form's memory block     */
  68. typedef HANDLE  HFIELD;         /* handle of a field's memory block    */
  69. typedef HANDLE  HBUTTON;        /* handle of a button's memory block   */
  70. typedef HBUTTON HGENCTRL;       /* handle of a generic control's block */
  71.  
  72. /*---------------------------------------------------------------------------*/
  73.  
  74. /* dialog control window procedure array info */
  75.  
  76. typedef struct {
  77.     HWND hWnd;                  /* window handle of the dialog control   */
  78.     FARPROC lpProc;             /* pointer to control's window procedure */
  79. }  PROC_ARRAY_INFO;
  80.  
  81. /*---------------------------------------------------------------------------*/
  82.  
  83. /* definition of a field record */
  84.  
  85. typedef struct {
  86.     HWND hwnd;                  /* field's window handle                     */
  87.     HWND hcombo;                /* handle of combo box field belongs to      */
  88.     HFIELD hfield;              /* field's memory handle                     */
  89.     HFIELD hnext_field;         /* handle of next field in linked list       */
  90.     int ctrl_id;                /* dialog control ID of edit control         */
  91.     LPVOID pdata;               /* pointer to data type to write/update      */
  92.     int data_type;              /* data type pointed to by 'data' parameter  */
  93.     LPSTR picture_string;       /* pointer to the field picture string       */
  94.     DWORD features;             /* field features                            */
  95.     int (FAR PASCAL *pvalid_func) (LPSTR); /* procedure-instance address of  */
  96.                                            /* field validation function      */
  97.     int error_value;            /* error value to pass to dialog callback    */
  98.     DWORD help_context;         /* help context ID of help topic for field   */
  99.     BOOL has_changed;           /* flag - "field has changed"                */
  100.     int logical_size;           /* logical size of field                     */
  101.     int physical_size;          /* physical size of field                    */
  102.     int decimal_position;       /* virtual logical position of decimal point */
  103. } FIELD;
  104.  
  105. typedef FIELD *     PFIELD;
  106. typedef FIELD FAR * LPFIELD;
  107.  
  108. /*---------------------------------------------------------------------------*/
  109.  
  110. /* field position information */
  111.  
  112. typedef struct {
  113.     long selection;             /* selection                               */
  114.     int physical_position;      /* physical position                       */
  115.     int logical_position;       /* logical position                        */
  116.     BOOL to_right_of_dec;       /* position is to the right of the decimal */
  117.     LPSTR ppicture_str_pos;     /* pointer to picture string position      */
  118.     int val_char_occ;           /* validation character occurrence         */
  119.     char validation_char;       /* validation character for position       */
  120. } FIELD_POS;
  121.  
  122. typedef FIELD_POS *     PFIELD_POS;
  123. typedef FIELD_POS FAR * LPFIELD_POS;
  124.  
  125. /*---------------------------------------------------------------------------*/
  126.  
  127. /* definition of a form record */
  128.  
  129. typedef struct {
  130.     HWND hdlg;                  /* form's dialog box window handle          */
  131.     HFORM hform;                /* form's memory handle                     */
  132.     HFORM hnext_form;           /* handle of next form in linked list       */
  133.     HFIELD hhead_field;         /* handle of head node in field list        */
  134.     HFIELD hcurr_field;         /* handle of current node in field list     */
  135.     HBUTTON hhead_button;       /* handle of head node in button list       */
  136.     HANDLE hproc_array;         /* handle of window procedure array         */
  137.     int num_controls;           /* number of defined controls in form       */
  138.     LPSTR help_file_name;       /* help file name                           */
  139.     int insert_id;              /* control ID of Insert status message      */
  140.     LPSTR insert_onmsg;         /* pointer to Insert "on" status message    */
  141.     LPSTR insert_offmsg;        /* pointer to Insert "off" status message   */
  142.     int capslock_id;            /* control ID of CapsLock status message    */
  143.     LPSTR capslock_onmsg;       /* pointer to CapsLock "on" status message  */
  144.     LPSTR capslock_offmsg;      /* pointer to CapsLock "off" status message */
  145.     int numlock_id;             /* control ID of NumLock status message     */
  146.     LPSTR numlock_onmsg;        /* pointer to NumLock "on" status message   */
  147.     LPSTR numlock_offmsg;       /* pointer to NumLock "off" status message  */
  148.     BOOL pressed_cancel;        /* flag - "Cancel was pressed"              */
  149.     BOOL error_condition;       /* flag - "an error has occured"            */
  150.     BOOL ignore_ok;             /* flag - "ignore the OK button"            */
  151.     BOOL edit_key_pressed;      /* flag - "an editing key was pressed"      */
  152.     BOOL just_passed_dec;       /* flag - "just passed decimal point"       */
  153.     BOOL insert_mode;           /* flag - "insert mode on"                  */
  154.     BOOL help_invoked;          /* flag - "Windows Help has been invoked"   */
  155. } FORM;
  156.  
  157. typedef FORM *     PFORM;
  158. typedef FORM FAR * LPFORM;
  159.  
  160. /*---------------------------------------------------------------------------*/
  161.  
  162. /* definition of a button record */
  163.  
  164. typedef struct {
  165.     HWND hwnd;                  /* button's window handle                   */
  166.     HBUTTON hbutton;            /* handle of button's window                */
  167.     HBUTTON hnext_button;       /* handle of next button in linked list     */
  168.     int ctrl_id;                /* dialog control ID of button              */
  169.     LPINT pdata;                /* pointer to data to initialize/update     */
  170.     int group_id;               /* group affiliation ID                     */
  171.     int on_value;               /* value stored at 'pdata' if checked       */
  172.     int off_value;              /* value stored at 'pdata' if not checked   */
  173.     DWORD help_context;         /* help context ID of help topic for button */
  174.     BOOL has_changed;           /* flag - "button has changed"              */
  175. } BUTTON;
  176.  
  177. typedef BUTTON *     PBUTTON;
  178. typedef BUTTON FAR * LPBUTTON;
  179.  
  180. /*---------------------------------------------------------------------------*/
  181.  
  182. /* function prototypes */
  183.  
  184. #if defined(__cplusplus)
  185.     #define NOARGS
  186.     extern "C" {
  187. #else
  188.     #define NOARGS void
  189. #endif
  190.  
  191. /* button functions */
  192.  
  193. HBUTTON FAR PASCAL button_define( HFORM hform, int ctrl_id, LPINT pdata,
  194.                                   int group_id, int on_value, int off_value,
  195.                                   int init_state, DWORD help_context );
  196. int      FAR PASCAL button_get_check( HBUTTON hbutton );
  197. HBUTTON  FAR PASCAL button_get_from_ctrl_id( HFORM hform, int ctrl_id );
  198. HBUTTON  FAR PASCAL button_get_from_group( HFORM hform, int group_id );
  199. HBUTTON  FAR PASCAL button_get_from_hwnd( HFORM hform, HWND hWnd );
  200. int      FAR PASCAL button_has_changed( HBUTTON hbutton );
  201. LPBUTTON FAR PASCAL button_lock( HBUTTON hbutton );
  202. int      FAR PASCAL button_set_check( HBUTTON hbutton, int state );
  203. void     FAR PASCAL button_unlock( HBUTTON hbutton );
  204.  
  205. /* character manipulation functions */
  206.  
  207. BOOL FAR PASCAL char_is_printable( int ch );
  208. int  FAR PASCAL char_to_lower( int ch );
  209. int  FAR PASCAL char_to_upper( int ch );
  210.  
  211. /* dialog procedure control functions */
  212.  
  213. int FAR PASCAL dproc_enter_error( HFORM hform );
  214. int FAR PASCAL dproc_enter_idcancel( HFORM hform );
  215. int FAR PASCAL dproc_enter_idok( HFORM hform );
  216. int FAR PASCAL dproc_enter_wm_command( HFORM hform, unsigned wParam,
  217.                                        LONG lParam );
  218. int FAR PASCAL dproc_exit_error( HFORM hform, LONG lParam );
  219.  
  220. /* field functions */
  221.  
  222. int     FAR PASCAL field_data_to_log( HFIELD hfield, LPSTR pbuf, LPVOID pdata,
  223.                                       int data_type );
  224. HFIELD  FAR PASCAL field_define( HFORM hform, int ctrl_id, LPVOID pdata,
  225.                                  int data_type, LPSTR picture_string,
  226.                                  DWORD features,
  227.                                  int (FAR PASCAL *pvalid_func) (LPSTR),
  228.                                  int error_value, DWORD help_context );
  229. int     FAR PASCAL field_disable_feature( HFIELD hfield, DWORD feature );
  230. int     FAR PASCAL field_enable_feature( HFIELD hfield, DWORD feature );
  231. int     FAR PASCAL field_get_character( HFIELD hfield, int position,
  232.                                         BOOL physical );
  233. int     FAR PASCAL field_get_decimal_pos( HFIELD hfield );
  234. HFIELD  FAR PASCAL field_get_from_ctrl_id( HFORM hform, int ctrl_id );
  235. HFIELD  FAR PASCAL field_get_from_hwnd( HFORM hform, HWND hWnd );
  236. int     FAR PASCAL field_get_pos_info( HFIELD hfield, int logical_position,
  237.                                        LPFIELD_POS pfpos );
  238. int     FAR PASCAL field_get_position( HFIELD hfield, LPFIELD_POS pfpos );
  239. int     FAR PASCAL field_get_text( HFIELD hfield, LPSTR pbuf, BOOL physical );
  240. int     FAR PASCAL field_has_changed( HFIELD hfield );
  241. int     FAR PASCAL field_insert_dec( HFIELD hfield, LPSTR pbuf );
  242. LPFIELD FAR PASCAL field_lock( HFIELD hfield );
  243. int     FAR PASCAL field_log_to_data( HFIELD hfield, LPSTR pbuf, LPVOID pdata,
  244.                                       int data_type );
  245. int     FAR PASCAL field_log_to_phys( HFIELD hfield, LPSTR pbuf );
  246. int     FAR PASCAL field_phys_to_log( HFIELD hfield, LPSTR pbuf );
  247. int     FAR PASCAL field_set_text( HFIELD hfield, LPSTR pbuf, BOOL physical );
  248. void    FAR PASCAL field_unlock( HFIELD hfield );
  249.  
  250. /* form functions */
  251.  
  252. HFORM  FAR PASCAL form_begin( HWND hDlg );
  253. int    FAR PASCAL form_end( HFORM hform );
  254. HFORM  FAR PASCAL form_get_active( NOARGS );
  255. HFORM  FAR PASCAL form_get_from_hdlg( HWND hDlg );
  256. int    FAR PASCAL form_has_changed( HFORM hform );
  257. int    FAR PASCAL form_in_error_cond( HFORM hform );
  258. int    FAR PASCAL form_is_cancelled( HFORM hform );
  259. LPFORM FAR PASCAL form_lock( HFORM hform );
  260. int    FAR PASCAL form_process( HFORM hform );
  261. int    FAR PASCAL form_set_help( HFORM hform, LPSTR help_file_name );
  262. int    FAR PASCAL form_terminate( HFORM hform );
  263. void   FAR PASCAL form_unlock( HFORM hform );
  264. HFIELD FAR PASCAL form_validate( HFORM hform );
  265.  
  266. /* generic control functions */
  267.  
  268. HGENCTRL FAR PASCAL genctrl_define( HFORM hform, int ctrl_id,
  269.                                     DWORD help_context );
  270.  
  271. /* status message functions */
  272.  
  273. int FAR PASCAL statmsg_define( HFORM hform, int ctrl_id, int which,
  274.                                LPSTR onmsg, LPSTR offmsg );
  275.  
  276. /* string manipulation functions */
  277.  
  278. int     FAR PASCAL str_delete_char( LPSTR pstr, int ch );
  279. void    FAR PASCAL str_insert_char( LPSTR pstr, int ch, int offs );
  280. BOOL    FAR PASCAL str_is_blank( LPSTR pstr );
  281. BOOL    FAR PASCAL str_is_value_zero( LPSTR pstr );
  282. void    FAR PASCAL str_trim_spaces( LPSTR pstr );
  283.  
  284. #if defined(__cplusplus)
  285.     }
  286. #endif
  287.  
  288.